package com.bgq365.study.springboot2.boot01helloworld;

import com.bgq365.study.springboot2.entities.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.interceptor.CacheAspectSupport;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
//@EnableConfigurationProperties(MyConstant.class)
//1、开启MyConstant配置绑定功能
//2、把这个MyConstant这个组件自动注册到容器中
public class Boot01HelloWorldMain {

    public static void main(String[] args) {
        //返回IOC容器
        ConfigurableApplicationContext run = SpringApplication.run(Boot01HelloWorldMain.class, args);

        //自动配置好了SpringMVC等
        //查看容器中的组件
        String[] names = run.getBeanDefinitionNames();
//        for (String name : names) {
//            System.out.println(name);
//        }
        System.out.println("===============");

        System.out.println(run.getBeanDefinitionCount());
        String[] names1 = run.getBeanNamesForType(CacheAspectSupport.class);
        for (String s : names1) {
            System.out.println(s);
        }
        System.out.println("===============");
        String[] beans = run.getBeanNamesForType(User.class);
        for (String bean : beans) {
            System.out.println(bean);
        }
        System.out.println("=============02===");
        System.out.println("容器中haha组件=" + run.containsBean("haha"));
    }
}
